package cn.niitcxl.services.impl;

import cn.niitcxl.domain.eduMessage;
import cn.niitcxl.mapper.MessageMapper;
import cn.niitcxl.services.MessageServices;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.logging.log4j.util.Strings;
import org.springframework.stereotype.Service;

@Service
public class MessageServiceImpl extends ServiceImpl<MessageMapper, eduMessage> implements MessageServices {
    @Override
    public IPage<eduMessage> getPage(Long currentPage,Long pageSize,String message) {
        //设置分页大小
        IPage<eduMessage> page = new Page<>(currentPage,pageSize);
        //设置条件对象
        QueryWrapper<eduMessage> queryWrapper = new QueryWrapper<>();
        if (Strings.isNotEmpty(message)){
            queryWrapper.like("message",message);
        }
        queryWrapper.orderByDesc("insert_date");
        IPage<eduMessage> selectPage = baseMapper.selectPage(page, queryWrapper);
        return selectPage;
    }
}